// 
//  Test_NoteInfo.cs
//  
//  Author:
//       Ray Shaw <demogodyou@gmail.com>
// 
//  Copyright (c) 2009 Ray Shaw(xiaolei)
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// 
//------------------------------------------------------------------------------
// <auto-generated>
//     此代码由工具生成。
//     运行时版本:2.0.50727.3053
//
//     对此文件的更改可能会导致不正确的行为，并且如果
//     重新生成代码，这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using SharpNote.Core.Entity;
using SharpNote.Core.Data;
using SharpNote.Core.Config;

namespace Test
{


	public class Test_NoteInfo : ITestCase
	{

		public Test_NoteInfo ()
		{
		}

		public bool Test ()
		{
			string signInPassword = "this is sign in password.";
			UserInfo userInfo = new UserInfo();
			userInfo.SetSignInPassword(signInPassword);
			userInfo.SetPrivateKey(signInPassword, "this is private key.");
			userInfo.ChangeSignInPassword(signInPassword, "x");
			
			string plainTextPrivateKey = string.Empty;
			bool privateKeyOK = userInfo.GetPrivateKeyPlainText(signInPassword, out plainTextPrivateKey);
			if(!privateKeyOK){ Console.WriteLine("Get PrivateKey value FAILED."); return false; }
			if(userInfo.GetPrivateKeyPlainText(signInPassword, out plainTextPrivateKey))
			{
			    SysConfig.GetInstance().PrivateKeyPlainText = plainTextPrivateKey;	
			}
			
			string key = SysConfig.GetInstance().PrivateKeyPlainText;
			for (int i = 0; i < 10; i++) {
				NoteInfo noteInfo = new NoteInfo ();
				noteInfo.Title = "this is the 标题.";
				noteInfo.Content = "this is the 内容.";

				noteInfo.Encrypt (key);
				
				Console.WriteLine (string.Format ("Create NoteInfo OK? {0}.", DbObjectMappingHelper.Create<NoteInfo> (noteInfo)));
			
				noteInfo.Decrypt(key);
				Console.WriteLine(string.Format("Title: {0}  Content: {1}", noteInfo.Title, noteInfo.Content));

			}


			return true;
		}

	}
}
